Skip to content

Comments

fix(transformer/styled-components): preserve spaces between consecutive interpolations in CSS minification#13346

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-28-fix_transformer_styled-components_preserve_spaces_between_consecutive_interpolations_in_css_minification
Aug 28, 2025
Merged

fix(transformer/styled-components): preserve spaces between consecutive interpolations in CSS minification#13346
graphite-app[bot] merged 1 commit intomainfrom
08-28-fix_transformer_styled-components_preserve_spaces_between_consecutive_interpolations_in_css_minification

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Aug 28, 2025

Fixes #13312

When minifying CSS in styled-components, spaces between consecutive interpolations were incorrectly removed, breaking CSS selectors.

Before: &:hover ${A}${B} (incorrect - space removed)
After: &:hover ${A} ${B} (correct - space preserved)

The fix modifies the whitespace handling logic to preserve spaces between consecutive interpolations while still removing unnecessary spaces elsewhere.

Copy link
Member Author

Dunqing commented Aug 28, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Dunqing Dunqing force-pushed the 08-28-fix_transformer_styled-components_preserve_spaces_between_consecutive_interpolations_in_css_minification branch from dbbad9a to 5ad0fa3 Compare August 28, 2025 03:07
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 28, 2025

CodSpeed Instrumentation Performance Report

Merging #13346 will not alter performance

Comparing 08-28-fix_transformer_styled-components_preserve_spaces_between_consecutive_interpolations_in_css_minification (7aff3b6) with main (bc0b471)1

Summary

✅ 38 untouched benchmarks

Footnotes

  1. No successful run was found on main (7aff3b6) during the generation of this report, so bc0b471 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Dunqing Dunqing force-pushed the 08-27-fix_transformer_legacy-decorator_emit_correct_metadata_types_for_enum branch from f9a7350 to 4b431b2 Compare August 28, 2025 03:10
@Dunqing Dunqing force-pushed the 08-28-fix_transformer_styled-components_preserve_spaces_between_consecutive_interpolations_in_css_minification branch from 5ad0fa3 to 1fa4dac Compare August 28, 2025 03:10
@Dunqing Dunqing force-pushed the 08-28-fix_transformer_styled-components_preserve_spaces_between_consecutive_interpolations_in_css_minification branch from 1fa4dac to 0c9f14c Compare August 28, 2025 13:35
@Dunqing Dunqing force-pushed the 08-27-fix_transformer_legacy-decorator_emit_correct_metadata_types_for_enum branch from 4b431b2 to cc3b0cf Compare August 28, 2025 13:35
Base automatically changed from 08-27-fix_transformer_legacy-decorator_emit_correct_metadata_types_for_enum to main August 28, 2025 15:23
@overlookmotel overlookmotel force-pushed the 08-28-fix_transformer_styled-components_preserve_spaces_between_consecutive_interpolations_in_css_minification branch from 0c9f14c to 6c12d0c Compare August 28, 2025 16:39
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Aug 28, 2025
Copy link
Member

overlookmotel commented Aug 28, 2025

Merge activity

…ve interpolations in CSS minification (#13346)

Fixes #13312

When minifying CSS in styled-components, spaces between consecutive interpolations were incorrectly removed, breaking CSS selectors.

**Before:** `&:hover ${A}${B}` (incorrect - space removed)
**After:** `&:hover ${A} ${B}` (correct - space preserved)

The fix modifies the whitespace handling logic to preserve spaces between consecutive interpolations while still removing unnecessary spaces elsewhere.
@graphite-app graphite-app bot force-pushed the 08-28-fix_transformer_styled-components_preserve_spaces_between_consecutive_interpolations_in_css_minification branch from 6c12d0c to 7aff3b6 Compare August 28, 2025 17:10
@graphite-app graphite-app bot merged commit 7aff3b6 into main Aug 28, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 08-28-fix_transformer_styled-components_preserve_spaces_between_consecutive_interpolations_in_css_minification branch August 28, 2025 17:15
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 28, 2025
graphite-app bot pushed a commit that referenced this pull request Aug 29, 2025
…inification (#13369)

Follow-on after #13346. Remove multiple spaces preceding `{`, `}`, `,`, or `;`.

Previously we removed a single space, but wouldn't remove multiple whitespace characters in a row.
graphite-app bot pushed a commit that referenced this pull request Aug 29, 2025
Fix a test case which was previously failing. The original test case in `babel-plugin-styled-components` *does* include a space before `height:`. Our copy of the test had got changed somehow (wrongly). This PR brings the case back into alignment with the original and, thanks to #13346, it now passes.

https://github.com/styled-components/babel-plugin-styled-components/blob/4e2eb388d9c90f2921c306c760657d059d01a518/test/fixtures/minify-single-line-comments-with-interpolations/output.js#L26-L29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Styled components minifier issues

2 participants